<template>
  <div id="left_navigation" class="navigation">
    <a href="/home/articleList" class="box"><i class="iconfont icon-liebiao"></i><span>list</span></a>
    <a href="/home" class="box"><i class="iconfont icon-cangku"></i><span>主页</span></a>
    <a href="/home/addArticle" class="box"><i class="iconfont icon-zhuti_tiaosepan"></i><span>添加文章</span></a>
    <a href="#" class="box"><i class="iconfont icon-qianbao"></i><span>wallet</span></a>
    <a href="#" class="box"><i class="iconfont icon-tupian"></i><span>picture</span></a>
    <a href="#" class="box"><i class="iconfont icon-erweima"></i><span>QR code</span></a>
    <a href="#" class="box"><i class="iconfont icon-dunpaibaoxianrenzheng"></i><span>authentication</span></a>
    <a href="#" class="box" @click="toLogout()"><i class="iconfont icon-dengchu"></i><span>cancellation</span></a>
  </div>
  <div id="fish-container" class="fish_container"></div>
  <div class="common-layout">
    <el-container>
      <el-header height="50px">
        <el-row :gutter="20">
          <el-col :span="4"><div class="grid-content ep-bg-purple" />
            <img src="../assets/logo.png" alt="logo" class="logo">
          </el-col>
          <el-col :span="16"><div class="grid-content ep-bg-purple" />
            <h2 class="xiaocubao-title">小醋包</h2>
          </el-col>
          <el-col :span="4"><div class="grid-content ep-bg-purple" />
            <UserAvatarComponent/>
          </el-col>
        </el-row>
      </el-header>
      <el-main>
        <router-view/>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import {create_fish} from '@/assets/js/get_func'
import {TOKEN} from '@/common/constants'
import router from "@/router";
import {logout} from "@/request/api/login";
import {getUserInfo} from "@/request/api/user";
import UserAvatarComponent from "@/components/UserAvatarComponent";


export default {
  components:{
    UserAvatarComponent
  },
  data() {
    const data = {
      userAccount: '',
      userEmail: ''
    }
    return {
      data
    }
  },
  setup() {
  },
  created() {
    getUserInfo().then(res => {
      this.data = res.data
    })
  },
  methods: {
    // 退出登陆
    toLogout() {
      // 发送登出请求
      logout().then(res => {
        console.log(res.data)
        // 移除 token
        localStorage.removeItem(TOKEN);
      })
      // 跳转到登陆页面
      router.push('/login')
    },
  },
  mounted() {
    create_fish()
  }
}
</script>

<style scoped>
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;

}

.logo {
  margin-left: 30px;
  height: 50px;
}
.xiaocubao-title {
  text-align: center;
  height: 50px;
  line-height: 50px;
}

a {
  text-decoration: none;
}

#left_navigation {
  position: fixed;
  left: .5%;
}

.navigation {
  top: 5%;
  width: 40px;
  height: 80%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  background-color: rgb(253, 249, 249);
  border-radius: 10px;
  transition: .3s;
  overflow: hidden;
  z-index: 2;
}

.box {
  display: block;
  height: 15%;
  width: 85%;
  margin: 9px;
  border-radius: 5px;
  position: relative;
  transition: .3s;
  color: rgb(160, 160, 175);
}

.box i {
  font-size: 30px;
  position: absolute;
  opacity: 0;
  padding: 20px 20px;
}

.box:nth-child(3)::before,
.box:nth-child(5)::before {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  background-color: rgb(142, 181, 243);
  position: absolute;
  bottom: -10px;
}

.box span {
  position: relative;
  top: 22px;
  left: 80px;
  font: 500 20px '';
  opacity: 0;
  transition: .3s;
}

.navigation:hover {
  width: 270px;
}

.box:hover {
  background-color: rgb(142, 181, 243);
}

.navigation:hover {
  background-color: rgb(241, 244, 248);
}

.navigation:hover span {
  opacity: 1;
  transition: .4s;
}

.navigation > a:hover {
  text-decoration: overline;
  transition: 0.5s;
}

.navigation:hover > .box i {
  opacity: 1;
  transition: .1s;
}

.box:hover {
  color: #f36060;
}

.navigation:nth-child(2) {
  background-color: rgb(243, 244, 246);
}

.navigation:nth-child(2) .box:hover {
  background-color: rgb(209, 213, 219);
  color: rgb(241, 159, 159);
}

.navigation:nth-child(2) .box {
  color: #e3a5a5;
}

.navigation:nth-child(3) {
  background-color: rgb(49, 46, 129);
}

.navigation:nth-child(3) .box:hover {
  background-color: rgb(125, 118, 217);
}

.navigation:nth-child(3) .box {
  color: rgb(154, 143, 213);
}

/*图标*/

@font-face {
  font-family: "iconfont"; /* Project id  */
  src: url('~@/assets/css/iconfont.ttf?t=1631366426941') format('truetype');
}

.iconfont {
  font-family: "iconfont", serif !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-tupian:before {
  content: "\eac4";
}

.icon-cangku:before {
  content: "\eac9";
}

.icon-zhuti_tiaosepan:before {
  content: "\eaec";
}

.icon-erweima:before {
  content: "\eaf1";
}

.icon-liebiao:before {
  content: "\eaf8";
}

.icon-dunpaibaoxianrenzheng:before {
  content: "\eb17";
}

.icon-qianbao:before {
  content: "\eb1a";
}

.icon-dengchu:before {
  content: "\eb45";
}

/*鱼缸*/
.fish_container {
  width: 100%;
  height: 20%;
  transform: translateY(450px);
  display: flex;
  position: fixed;
  bottom: 450px;
  left: 0;
  z-index: 0;
  background-color: #FFFFFF;
}
</style>